<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use BackupManager\Manager;

class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        \App\Console\Commands\LogDemo::class,
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        // 备份数据库
        $name = \Carbon\Carbon::now()->format('Y-m-d').'-'.strtolower(str_random(6));

        $schedule->command(
            "db:backup --database=mysql --destination=local --destinationPath='{$name}' --compression=gzip"
        )->daily();
    }
}
